/*
 * login.js
 */

$(function(){

    $('.login button').on('click', function(e){
        var username = $('input[name=username]').val();
        var password = $('input[name=password]').val();
        if(!username || !password){
            alert('请输入用户名和密码')
            return;
        }
        login(username, password);
    })


    function login(user, pwd){
        loading = true;
        $.ajax({
            url: config.base_api + '/api/rest/login/admin',
            data: {
                name: user,
                verify: pwd
            }
        }).then(function(ret){
            console.log('login success', ret)
            showList();
        }, function(err){
            console.log(err);
            alert(err.message || '登录失败')
        })
    }

    function showList(){
        console.log('index.html');
        location.href = 'index.html'
    }

})

